import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const commonRoutes = [{
		path: '/login',
		name: 'login',
		component: () => import('../components/Login.vue')
	},
	{
		path: '/',
		redirect: '/home'
	},
]

// 需要通过后台数据来生成的组件
export const asyncRoutes = {
	'home': {
		path: 'home',
		name: 'home',
		component: () => import('@/views/Home.vue')
	},
	't1': {
		path: 't1',
		name: 't1',
		component: () => import('@/views/T1.vue')
	},
	'password': {
		path: 'password',
		name: 'password',
		component: () => import('@/views/Password.vue')
	},
	'msg': {
		path: 'msg',
		name: 'msg',
		component: () => import('@/views/Msg.vue')
	},
	'userinfo': {
		path: 'userinfo',
		name: 'userinfo',
		component: () => import('@/views/UserInfo.vue')
	},
	'user': {
		path: 'user',
		name: 'user',
		component: () => import('@/views/system/user.vue')
	},
	'dict': {
		path: 'dict',
		name: 'dict',
		component: () => import('@/views/system/dict.vue')
	},
	'dictinfo': {
		path: 'dictinfo',
		name: 'dictinfo',
		component: () => import('@/views/system/dictinfo.vue')
	},
	'menu': {
		path: 'menu',
		name: 'menu',
		component: () => import('@/views/system/menu.vue')
	},
	'role': {
		path: 'role',
		name: 'role',
		component: () => import('@/views/system/role.vue')
	},
	'permissions': {
		path: 'permissions',
		name: 'permissions',
		component: () => import('@/views/system/permissions.vue')
	},
	
}

const createRouter = () => new Router({
	routes: commonRoutes
})

const router = createRouter()

export function resetRouter() {
	const newRouter = createRouter()
	router.matcher = newRouter.matcher
}

export default router